//
//  WLTabViewController.m
//  KnowEveryThings
//
//  Created by lanou3g on 16/5/4.
//  Copyright © 2016年 王玲. All rights reserved.
//

#import "WLTabViewController.h"
#import "WLTVViewController.h"
#import "WLMainViewController.h"
#import "UIImage+image.h"
#import "WLReadingController.h"
#import "IViewController.h"
@interface WLTabViewController ()

@end

@implementation WLTabViewController

///设置tabbar字体的颜色
+(void)initialize{
    
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
    dict[NSForegroundColorAttributeName] = [UIColor orangeColor];
    [item setTitleTextAttributes:dict forState:(UIControlStateSelected)];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupChildViewController];
    
    
}

- (void)setupChildViewController{
    //新闻的tabbar
    WLMainViewController *mainViewController = [[WLMainViewController alloc] init];
    UINavigationController *mainNavc = [[UINavigationController alloc] initWithRootViewController:mainViewController];
    [self setUpViewController:mainNavc SelectImage:[UIImage imageWithOriginaName:@"headLines2.png"] UnSelectImage:[UIImage imageWithOriginaName:@"headLines1.png"] ItemTitle:@"新闻"];
    
     //阅读的tabbar
    WLReadingController *readViewController = [[WLReadingController alloc] init];
    UINavigationController *readNavc = [[UINavigationController alloc] initWithRootViewController:readViewController];
    [self setUpViewController:readNavc SelectImage:[UIImage imageWithOriginaName:@"reading2.png"] UnSelectImage:[UIImage imageWithOriginaName:@"reading1.png"] ItemTitle:@"阅读"];
    
     //视频的tabbar
    WLTVViewController *TVController = [[WLTVViewController alloc] init];
    UINavigationController *TVNavc = [[UINavigationController alloc] initWithRootViewController:TVController];
    [self setUpViewController:TVNavc SelectImage:[UIImage imageWithOriginaName:@"TV2.png"] UnSelectImage:[UIImage imageWithOriginaName:@"TV1.png"] ItemTitle:@"视频"];
    
    //我 的tabbar
    IViewController *iViewController = [[IViewController alloc] init];
    UINavigationController *Inavc = [[UINavigationController alloc] initWithRootViewController:iViewController];
    [self setUpViewController:Inavc SelectImage:[UIImage imageWithOriginaName:@"I2.png"] UnSelectImage:[UIImage imageWithOriginaName:@"I1.png"] ItemTitle:@"我"];
    
    self.viewControllers = @[mainNavc,readNavc,TVNavc,Inavc];
    
}


//添加一个字控制器
- (void)setUpViewController:(UIViewController *)viewController SelectImage:(UIImage *)selectImage UnSelectImage:(UIImage *)unSelectImage ItemTitle:(NSString *)title{
    
    viewController.tabBarItem.selectedImage = selectImage;
    viewController.tabBarItem.image = unSelectImage;
    viewController.tabBarItem.title = title;
    [self addChildViewController:viewController];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
